package com.qiyu.constant;

import lombok.Getter;

import java.util.stream.Stream;

/**
 * 一级菜单 枚举
 */
@Getter
public enum FirstLevelMenuEnum {
    
    home(1, 1L, "首页", false),
    overview(2, 2L, "度假区概况", false),
    product(3, 3L, "度假区产品", true),
    strategy(4, 4L, "度假攻略", false),
    information(5, 5L, "信息动态", false),
    purchase(6, 6L, "在线预订", false);
    
    /**
     * 标识
     */
    private Integer code;
    
    /**
     * 对应表first_level_menu的id
     */
    private Long dbId;
    
    /**
     * 菜单中文名称
     */
    private String nameCn;
    
    /**
     * 是否支持子类型(扩展菜单)
     */
    private Boolean supportSubType;
    
    
    FirstLevelMenuEnum(Integer code, Long dbId, String nameCn, Boolean supportSubType) {
        this.code = code;
        this.dbId = dbId;
        this.nameCn = nameCn;
        this.supportSubType = supportSubType;
    }
    
    /**
     * 获取一级菜单的key
     */
    public String getMenuKey() {
        return this.name().toLowerCase();
    }
    
    public static FirstLevelMenuEnum getByDbId(Long dbId) {
        return Stream.of(FirstLevelMenuEnum.values())
                .filter(menuEnum -> menuEnum.getDbId().equals(dbId))
                .findFirst()
                .orElse(null);
    }
    
    /*public FirstLevelMenuEnum getMenuDetail() {
        return null;
    }*/
    
    
}
